package com.briup.pts.web.controller;

import com.briup.pts.entity.QuarantineRegistration;
import com.briup.pts.mapper.QuarantineRegistrationMapper;
import com.briup.pts.result.Result;
import com.briup.pts.service.QuarantineRegistrationService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "检疫登记模块")
@RestController
@RequestMapping("/quarantineRegistration")
public class QuarantineController {

    @Autowired
    private QuarantineRegistrationService quarantineRegistrationService;

    @GetMapping
    public Result findAllByPage(String bQualified,
                                String grMechanism,
                                @RequestParam Integer pageNum,
                                @RequestParam Integer pageSize) {
        PageInfo<QuarantineRegistration> pageInfo = quarantineRegistrationService.findAllByPage(bQualified, grMechanism, pageNum, pageSize);
        return Result.success(pageInfo);
    }

    @PostMapping("/saveOrUpdate")
    public Result saveOrUpdate(@RequestBody QuarantineRegistration quarantineRegistration){
        quarantineRegistrationService.saveOrUpdate(quarantineRegistration);
        return Result.success();
    }

    @DeleteMapping("/deleteById/{id}")
    public Result deleteById(@PathVariable Integer id){
        quarantineRegistrationService.removeById(id);
        return Result.success();
    }

    @DeleteMapping("/deleteByIdAll")
    public Result deleteByIdAll(@RequestBody List<Integer> ids){
        quarantineRegistrationService.removeBatch(ids);
        return Result.success();
    }



}
